﻿using System.Windows.Input;
using EDMDesigner.Designer.Controls.CSDLType.Resources;
using EDMDesigner.Designer.Controls.Util;

namespace EDMDesigner.Designer.Controls.Relations
{
    partial class Association
    {
        private IEDMDesignerWindow Window
        {
            get
            {
                return FromTypeDesigner.Designer.Window;
            }
        }

        private static RoutedCommand _deleteCommand;
        public static RoutedCommand DeleteCommand
        {
            get
            {
                if (_deleteCommand == null)
                    _deleteCommand = new RoutedCommand();
                return _deleteCommand;
            }
        }
        public static string DeleteText
        {
            get
            {
                return MenuResources.Delete;
            }
        }

        private static RoutedCommand _propertiesCommand;
        public static RoutedCommand PropertiesCommand
        {
            get
            {
                if (_propertiesCommand == null)
                    _propertiesCommand = new RoutedCommand();
                return _propertiesCommand;
            }
        }
        public static string PropertiesText
        {
            get
            {
                return MenuResources.Properties;
            }
        }

        private static RoutedCommand _mappingCommand;
        public static RoutedCommand MappingCommand
        {
            get
            {
                if (_mappingCommand == null)
                    _mappingCommand = new RoutedCommand();
                return _mappingCommand;
            }
        }
        public static string MappingText
        {
            get
            {
                return MenuResources.Mapping;
            }
        }

        private void InitContextMenuCommandBindings()
        {
            CommandBindings.AddRange(
                new[]
                {
                    new CommandBinding(DeleteCommand,
                        delegate 
                        {
                            CSDLAssociation.PropertyEnd1.EntityType.NavigationProperties.Remove(CSDLAssociation.PropertyEnd1);
                        }
                    ),
                    new CommandBinding(PropertiesCommand,
                        delegate
                        {
                            Window.ShowPropertiesTab();
                        }
                    ),
                    new CommandBinding(MappingCommand,
                        delegate 
                        {
                            Window.ShowMappingTab();
                        }
                    )
                });
        }
    }
}
